﻿IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'proc_cm_SaveDatabaseContent')
BEGIN
    PRINT 'Dropping Procedure proc_cm_SaveDatabaseContent'
    DROP  Procedure  proc_cm_SaveDatabaseContent
END
GO

PRINT 'Creating Procedure proc_cm_SaveDatabaseContent'
GO

CREATE Procedure dbo.proc_cm_SaveDatabaseContent
	@pContentId int = null
	,@pContentCd varchar(50)
	,@pContentTxt ntext
	,@pContentHtmlTxt ntext
	,@pHtmlPageId uniqueidentifier
	,@pDisplaySectionheaderInd bit
	,@pSectionheaderTxt nvarchar(128) = null
	,@pDividerColorTxt varchar(50) = null
	,@pPriorityNum int
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

	if @pContentId is not null
	begin
		update
			[dbo].[tbl_v2_Content]
		set
			[content_txt] = @pContentTxt
			,[update_dttm] = getdate()
			,[content_html_txt] = @pContentHtmlTxt
			,[display_sectionheader_ind] = @pDisplaySectionheaderInd
			,[sectionheader_txt] = @pSectionheaderTxt
			,[divider_color_txt] = @pDividerColorTxt
			,[priority_num] = @pPriorityNum
		where
			[content_cd] = @pContentCd
	end
END
GO

GRANT EXEC ON dbo.proc_cm_SaveDatabaseContent TO PUBLIC
GO

